#include <iostream>
using namespace std;


class Person {
public:
	int* age;
	int* height;
    string* name;
	//无参（默认）构造函数
public:
	Person() {
		cout << "无参构造函数!" << endl;
	}
	//有参构造函数
	Person(int age, int height, string name) {
		cout << "有参构造函数!" << endl;
		this->age = new int(age);
		this->height = new int(height);
        this->name = new string(name);
	}
	//拷贝构造函数
	Person(const Person& p) {
		cout << "拷贝构造函数!" << endl;
		//如果不利用深拷贝在堆区创建新内存，会导致浅拷贝带来的重复释放堆区问题
		this->age = new int(*p.age);
		this->height = new int(*p.height);
        this->name = new string(*p.name);
	}

	//析构函数
	~Person() {
		cout << "析构函数!" << endl;
		if (age != nullptr) {
			delete age;
		}
        if (height != nullptr) {
            delete height;
        }
        if (name != nullptr) {
            delete name;
        }
	}
};